1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to compilers. Still more particularly, the present invention relates to a computer implemented method, apparatus, and a computer usable program product for performing code specialization during compile time.
2. Description of the Related Art
Compilers are used to transform a program written in a first language to a second language. Most often, a computer program is translated from source code written in a language that is easily read by humans into executable code written in a language that can be easily used by a computer. Computer programmers often seek ways to maximize the efficiency of executable code during the compilation process. This process is called “optimization”. The word “optimization” and related terms are terms of art that refer to improvements in speed and/or efficiency of a computer program, and do not purport to indicate that a computer program has achieved, or is capable of achieving, an “optimal” or perfectly speedy or perfectly efficient state.
A problem associated with optimizing executable code concerns how the executable code performs memory access. Because the addresses of memory locations being accessed are not known until the executable program is executed, the compiler often takes a conservative approach and executes memory accesses commands in the sequential order of the source code. To prevent errors during memory access, the compiler usually places artificial dependencies between memory references to ensure that the memory references are executed in sequential order.
One form of compilation optimization related to memory access commands in the source code is known as memory disambiguation. A given set of memory access commands is considered ambiguous if the compiler cannot determine whether the memory access commands access different regions of memory. A given set of memory access commands is not considered ambiguous if the compiler can determine that the memory access commands do not access the same memory region. Memory disambiguation refers to performing analysis on code during compile time to determine whether real dependencies actually exist for a pair of ambiguous memory references.
Ambiguous memory references have traditionally been one of the main sources of performance bottlenecks in the final executable program. Static disambiguation techniques have been proposed and used when memory access patterns of the program are linear and predictable. However, these static techniques are ineffective when the memory access pattern is non-linear or when the access program cannot be determined statically.
Specializing source code with respect to runtime values is an optimization strategy that has been shown to drastically improve code performance on executable programs. Runtime is the time in which executable code is executed. Program specialization speeds up program execution by selectively executing different optimized versions of the program code, depending on the circumstances that actually exist at runtime. Code specialization can be applied to the compiler transformation in order to provide alternate paths of control to be followed based upon the results of runtime memory ambiguity checks. However, runtime memory ambiguity checks can introduce additional computing overhead, which is undesirable.